//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_ffunc.sqf"
#include "x_setup.sqf"

private ["_l","_vUp","_winkel","_objs","_dist"];
if (vehicle player == player) then {
	GVAR(objectID1) = objNull;
	_objs = nearestObjects [player, ["LandVehicle"], 10];
	if (count _objs > 0) then { GVAR(objectID1) = _objs select 0; };
	if (!alive GVAR(objectID1) || {player distance GVAR(objectID1) > 8}) then {
		false
	} else {
		_vUp = vectorUp GVAR(objectID1);
		// TYRGHEN
		// if ((_vUp select 2) < 0 && {player distance (position player nearestObject GVAR(rep_truck)) < 20}) then {
			// true
		// } else {
			// _l=sqrt((_vUp select 0)^2+(_vUp select 1)^2);
			// if (_l != 0) then {
				// _winkel = (_vUp select 2) atan2 _l;
				// (_winkel < 30 && {player distance (position player nearestObject GVAR(rep_truck)) < 20})
			// }
		// }
		private "_has_toolkit";
		_has_toolkit = ("ToolKit" in (items player) || GVAR(string_player) in GVAR(is_engineer));
		if ((_vUp select 2) < 0 && (_has_toolkit || {player distance (position player nearestObject GVAR(rep_truck)) < 20})) then {
			true
		} else {
			_l=sqrt((_vUp select 0)^2+(_vUp select 1)^2);
			if (_l != 0) then {
				_winkel = (_vUp select 2) atan2 _l;
				(_winkel < 30 && _has_toolkit)
			}
		}
	}
} else {
	false
}